package com.woke.adapter;

import java.util.ArrayList;
import java.util.List;
import cn.xl.xxl.imagecache.ImageLoader;

import com.zhongcai.online.R;
import com.woke.data.Datas_perbor2;
import com.woke.method.Bitmapr;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Creditboradter extends BaseAdapter{
	private LayoutInflater mInflater;
	private List<Datas_perbor2> datalist;
	private ImageLoader imageLoader;
	private Bitmapr bit;

	public Creditboradter(LayoutInflater minflater, ArrayList<Datas_perbor2> datalist,ImageLoader imageLoader) {
		this.mInflater = minflater;
		this.datalist = datalist;
		this.imageLoader = imageLoader;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return datalist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	class Holder {
		ImageView mImage_icon;
		TextView mText_time;
		TextView mText_lili;
		TextView mText_name;
		TextView mText_money,mText_adress;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if(convertView == null){
			holder = new Holder();
			convertView = mInflater.inflate(R.layout.item_adapter_person, null);
			holder.mImage_icon = (ImageView) convertView.findViewById(R.id.item_personbo_icon);
			holder.mText_time = (TextView) convertView.findViewById(R.id.item_personbo_day);
			holder.mText_lili = (TextView) convertView.findViewById(R.id.item_personbo_lili);
			holder.mText_name = (TextView) convertView.findViewById(R.id.item_personbo_name);
			holder.mText_money = (TextView) convertView.findViewById(R.id.item_personbo_money);
			holder.mText_adress = (TextView) convertView.findViewById(R.id.item_personbo_adress);
			convertView.setTag(holder);
		}else{
			 holder = (Holder) convertView.getTag();
		}
		Datas_perbor2 data = datalist.get(position);
		holder.mText_time.setText(" "+data.getExp_date()+"天"+"  ");
		holder.mText_lili.setText(""+data.getQuota_use());
		holder.mText_name.setText(data.getUser_nicename());
		holder.mText_adress.setText(data.getProvince_id()+data.getCity_id());
		Double money = Double.valueOf(data.getQuota_money());
		
		if(null != data.getAvatar() && !data.getAvatar().equals("")){
			imageLoader.DisplayImage("http://"+data.getAvatar(), holder.mImage_icon, false, true, false,0);
		}
		if((money - 10000) >= 0){
			Double reust = money / 10000;
			holder.mText_money.setText(" "+reust+"万");
		}else{
			holder.mText_money.setText(" "+data.getQuota_money()+"元");
		}
		return convertView;
	}

}
